﻿using GameToolkit.BehaviourTree;

namespace GameToolkit.Task
{
    [System.Serializable]
    [CompositeCategory("")]
    [CompositeTitle("Entry", Description = "The multi tasks entry.")]
    [CompositeIcon("c6a4af62aa596c243a0e90eda2d381f7")]
    public class TaskEntryNode : TaskNode
    {
        public override TaskEntity Create()
        {
            return new Impl();
        }

        class Impl : TaskEntity
        {
            protected override void OnEnter(TaskGraph graph)
            {
                if (State != ETaskState.Complete)
                    SetState(ETaskState.Complete);
            }

            protected override void OnExit(TaskGraph graph)
            {
                SetState(ETaskState.Inactive);
            }
        }
    }
}
